/*
* Copyright 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package com.laihuichuxing.train.provider;

import com.alibaba.dubbo.config.annotation.Service;
import com.laihuichuxing.common.util.NumUtil;
import com.laihuichuxing.config.ParameterConfig;
import com.laihuichuxing.order.train.api.OpTicketServerApi;
import com.laihuichuxing.train.dao.OPticketDAO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * Description:
 *
 * @author: Qinxuefeng
 * @since: 1.0
 * Create Date Time: 2018/12/14 14:47
 * Update Date Time:
 */
@Service(version = "1.0.0",interfaceClass = OpTicketServerApi.class)
public class OpTicketServerProvider implements OpTicketServerApi{
    @Autowired
    private OPticketDAO oPticketDAO;
    @Override
    public Map<String, Object> pottingTrainOrder(Map<String, Object> resultMap, String driverTradeNo) {
        Map<String, Object> map = oPticketDAO.selectOrder(driverTradeNo);
        resultMap.put(ParameterConfig.ORIGIN, "火车票支付");
        String trainDate = map.get("trainDate").toString();
        String departureTime = trainDate.substring(0, 4) + "-" + trainDate.substring(4, 6) + "-" + trainDate.substring(6, 8) + " " + map.get("fromTime");
        String priceString = oPticketDAO.getPrice(driverTradeNo);
        resultMap.put(ParameterConfig.PRICE, NumUtil.parseDouble(priceString,2));
        resultMap.put(ParameterConfig.PAYTIME, map.get("create_time"));
        resultMap.put(ParameterConfig.TRADENO, driverTradeNo);
        resultMap.put(ParameterConfig.DEPARTURETIME, departureTime);
        resultMap.put(ParameterConfig.START, map.get("fromStation"));
        resultMap.put("end", map.get("toStation"));
        resultMap.put(ParameterConfig.PAYTYPE, "支付宝");
        resultMap.put(ParameterConfig.STATUS, "支付成功");
        return resultMap;
    }

    @Override
    public Map<String, Object> cancelOrder(Map<String, String> map, Integer integer, Integer integer1) {
        return null;
    }
}
